package org.finesys.common.disruptor.context;

import org.finesys.common.disruptor.context.event.DisruptorEventPublisher;
import org.finesys.common.disruptor.event.DisruptorApplicationEvent;
import org.finesys.common.disruptor.event.DisruptorEvent;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class DisruptorApplicationContext implements ApplicationContextAware, DisruptorEventPublisher {

    protected ApplicationContext applicationContext;

    @Override
    public void publishEvent(DisruptorEvent event) {
        applicationContext.publishEvent(new DisruptorApplicationEvent(event));
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public ApplicationContext getApplicationContext() {
        return applicationContext;
    }

}